<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Constructs a new tidy object</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="tidy.cleanrepair.html">tidy::cleanRepair</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="tidy.diagnose.html">tidy::diagnose</a></div>
 <div class="up"><a href="class.tidy.html">tidy</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="tidy.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">tidy::__construct</h1>
  <p class="verinfo">(PHP 5, PECL tidy &gt;= 0.5.2)</p><p class="refpurpose"><span class="refname">tidy::__construct</span> &mdash; <span class="dc-title">Constructs a new <a href="class.tidy.html" class="classname">tidy</a> object</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-tidy.construct-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>tidy::__construct</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$config</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$encoding</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$use_include_path</code></span>
  ]]]] )</div>

  <p class="para rdfs-comment">
   Constructs a new <a href="class.tidy.html" class="classname">tidy</a> object.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-tidy.construct-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">filename</code></em></dt>

     <dd>

      <p class="para">
       If the <em><code class="parameter">filename</code></em> parameter is given, this function
       will also read that file and initialize the object with the file,
       acting like <span class="function"><a href="tidy.parsefile.html" class="function">tidy_parse_file()</a></span>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">config</code></em></dt>

     <dd>

      <p class="para">
       The config <em><code class="parameter">config</code></em> can be passed either as an
       array or as a string. If a string is passed, it is interpreted as the
       name of the configuration file, otherwise, it is interpreted as the
       options themselves.
      </p>
      <p class="para">
       For an explanation about each option, visit <a href="http://tidy.sourceforge.net/docs/quickref.html" class="link external">&raquo;&nbsp;http://tidy.sourceforge.net/docs/quickref.html</a>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">encoding</code></em></dt>

     <dd>

      <p class="para">
       The <em><code class="parameter">encoding</code></em> parameter sets the encoding for
       input/output documents. The possible values for encoding  are: 
       <em>ascii</em>, <em>latin0</em>, <em>latin1</em>,
       <em>raw</em>, <em>utf8</em>, <em>iso2022</em>,
       <em>mac</em>, <em>win1252</em>, <em>ibm858</em>,
       <em>utf16</em>, <em>utf16le</em>, <em>utf16be</em>,
       <em>big5</em>, and <em>shiftjis</em>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">use_include_path</code></em></dt>

     <dd>

      <p class="para">
       Search for the file in the <a href="ini.core.html#ini.include-path" class="link">include_path</a>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-tidy.construct-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the new <a href="class.tidy.html" class="classname">tidy</a> instance.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-tidy.construct-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3951">
    <p><strong>Example #1 <span class="function"><strong>tidy::__construct()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$html&nbsp;</span><span style="color: #007700">=&nbsp;&lt;&lt;&lt;&nbsp;HTML<br /></span><span style="color: #DD0000"><br />&lt;!DOCTYPE&nbsp;html&nbsp;PUBLIC&nbsp;"-//W3C//DTD&nbsp;XHTML&nbsp;1.0&nbsp;Strict//EN"<br />"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;<br /><br />&lt;html&nbsp;xmlns="http://www.w3.org/1999/xhtml"&nbsp;xml:lang="en"&nbsp;lang="en"&gt;<br />&lt;head&gt;&lt;title&gt;title&lt;/title&gt;&lt;/head&gt;<br />&lt;body&gt;<br />&lt;p&gt;paragraph&nbsp;&lt;bt&nbsp;/&gt;<br />text&lt;/p&gt;<br />&lt;/body&gt;&lt;/html&gt;<br /><br /></span><span style="color: #007700">HTML;<br /><br /></span><span style="color: #0000BB">$tidy&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">tidy</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$tidy</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">ParseString</span><span style="color: #007700">(</span><span style="color: #0000BB">$html</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$tidy</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">cleanRepair</span><span style="color: #007700">();<br /><br />if&nbsp;(</span><span style="color: #0000BB">$tidy</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">errorBuffer</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;following&nbsp;errors&nbsp;were&nbsp;detected:\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$tidy</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">errorBuffer</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
The following errors were detected:
line 8 column 14 - Error: &lt;bt&gt; is not recognized!
line 8 column 14 - Warning: discarding unexpected &lt;bt&gt;
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-tidy.construct-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="tidy.parsefile.html" class="function" rel="rdfs-seeAlso">tidy::parseFile()</a> - Parse markup in file or URI</span></li>
   <li class="member"><span class="function"><a href="tidy.parsestring.html" class="function" rel="rdfs-seeAlso">tidy::parseString()</a> - Parse a document stored in a string</span></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="tidy.cleanrepair.html">tidy::cleanRepair</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="tidy.diagnose.html">tidy::diagnose</a></div>
 <div class="up"><a href="class.tidy.html">tidy</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
